<!--售票员票款差异审核-->
<template>
  <div class="conductorTicketChaYiShenhe">
    <basic-container>
      <avue-crud
        ref="conductorTicketChaYiShenhe"
        :option="option"
        :table-loading="listLoading"
        :data="list"
	:permission="permissionList"
        :page.sync="page"
        :search.sync="searchForm"
        @search-change="handleFilter"
        @selection-change="selectionChange"
        @refresh-change="refreshChange"
        @on-load="refreshChange"
        :row-style="rowStyle"
        :cell-style="cellStyle">
        <template slot-scope="scope" slot="menuRight">
          <!--<el-button type="primary"  size="mini" @click="addData()">添加</el-button>-->
          <el-button type="primary" size="mini" @click="jiaRuXieCha()">加入协查</el-button>
          <el-button type="primary" size="mini" @click="jiaRuNotice()">加入确认通知</el-button>
          <el-button type="primary" size="mini" @click="audit_state_pass()">审批通过</el-button>
          <el-button type="primary" size="mini"  @click="revoke">撤回审核</el-button>
          <el-button type="primary" size="mini" @click="mergePersonData">合并结算</el-button>
          <el-button type="primary" size="mini" @click="submitData">加入报表差错</el-button>
          <el-button class="filter-item" type="primary" size="mini" @click="cancellationData()">作废BOM数据</el-button>
	  <el-button type="primary" size="mini" @click="handleDelete">删除</el-button>
	  <el-button type="primary" size="mini"  v-permission="permissionList.highDelBomRepeatData" @click="handleDeleteRepeat">删除重复提交</el-button>
          <el-button type="primary" size="mini" @click="exportData">导出</el-button>

        </template>
        <template slot-scope="scope" slot="lineCodeSearch">
          <el-select v-model="searchForm.lineCode" placeholder="请选择" style="width: 150px" @change="changeLine" filterable
                     clearable>
            <el-option
              v-for="(item,index) in lineCodes"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="stationCodeSearch">
          <el-select v-model="searchForm.stationCode" placeholder="请选择" style="width: 150px" clearable filterable
                     @change="changeStation">
            <el-option
              v-for="(item,index) in stationCodes"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="conductorPersonNameSearch">
          <el-select v-model="searchForm.conductorPersonName" placeholder="请选择" style="width: 150px" clearable
                     filterable>
            <el-option
              v-for="(item,index) in conductorPersonNames"
              :key="index"
              :label="item.nikename"
              :value="item.nikename">
            </el-option>
          </el-select>
        </template>
        <template slot="search" slot-scope="{row,size}">
            <el-form-item label="差异条件" style="width: 200px">
              <el-select v-model="searchForm.isDifferenceAmount" placeholder="请选择" style="width: 200px" clearable>
              <el-option label="不等于0" value="0"></el-option>
              <el-option label="等于0" value="1"></el-option>
              <!-- <el-option label="大于0" value="2"></el-option> -->
              </el-select>
            </el-form-item>
            <el-form-item label="审核状态" style="width: 200px">
              <el-select v-model="searchForm.auditState" placeholder="请选择"  style="width: 200px" clearable>
                <el-option label="未审核" value="0"></el-option>
                <el-option label="审核通过" value="1"></el-option>
              </el-select>
            </el-form-item>
        </template>
        <template slot="searchMenu" slot-scope="{row,size}">
          <el-button :size="size" @click="()=>{setSearchFiledsEmpty(row);setSearchFiledsEmpty(searchForm);getList()}"
                     icon="el-icon-delete">清空
          </el-button>
        </template>
        <template slot-scope="scope" slot="menu">
<!--          <el-button type="text" size="small" v-if="scope.row.dataSource==2 && scope.row.auditState==0" plain @click.stop="editor(scope.row)">编辑</el-button>-->
          <el-button type="text" size="small" v-if="scope.row.auditState==0 " plain @click.stop="editor(scope.row)">编辑</el-button>
          <el-button type="text" size="small" plain @click.stop="openPastRecords(scope.row)">查看历史记录</el-button>
          <el-button type="text" size="small" v-if="scope.row.isHaveBus==1" plain @click.stop="lookChengkeShiwu(scope.row)">查看乘客事务</el-button>
          <el-button type="text" size="small" plain @click.stop="openReplace(scope.row)">数据来源替换</el-button>
          <el-button type="text" size="small" v-if="scope.row.assitAuditSate!=0" plain @click.stop="xieChaInfo(scope.row)">协查信息</el-button>
          <el-button type="text" size="small" v-if="scope.row.isMergeRecord==1" @click.stop="openMergeInfo(scope.row)">合并信息</el-button>
          <el-button type="text" size="small" v-if="scope.row.isAddLayerError==1" plain @click.stop="cengJiXieCha(scope.row)">层级差异</el-button>
          <el-button type="text" size="small" v-if="scope.row.isHaveMarket==1" plain @click.stop="actionMarketTicket(scope.row)">营销车票</el-button>
          <el-button type="text" size="small" v-if="scope.row.noticeSate>1" plain @click.stop="previewNotice(scope.row)">售票员确认通知</el-button>
          <!--          <el-button type="text" size="small" v-if="scope.row.dataSource==2 && scope.row.auditState==0" plain @click.stop="editor(scope.row)">编辑</el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.auditState==0" plain @click.stop="editor(scope.row)">编辑-->
<!--          </el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.isHaveBus==1" plain-->
<!--                     @click.stop="lookChengkeShiwu(scope.row)">查看乘客事务-->
<!--          </el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.auditState==0" plain @click.stop="openReplace(scope.row)">-->
<!--            数据来源替换-->
<!--          </el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.assitAuditSate!=0" plain-->
<!--                     @click.stop="xieChaInfo(scope.row)">协查信息-->
<!--          </el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.isMergeRecord==1" @click.stop="openMergeInfo(scope.row)">-->
<!--            合并信息-->
<!--          </el-button>-->
<!--          <el-button type="text" size="small" v-if="scope.row.isAddLayerError==1" plain-->
<!--                     @click.stop="cengJiXieCha(scope.row)">层级差异-->
<!--          </el-button>-->
        </template>
      </avue-crud>
      <open-dialog
        :DialogVisible.sync="visableDialogRecordsSC"
        title="查看历史记录"
        width="60%"
      >
        <avue-crud
          :data="tableData"
          :option="tableOptionEditRecordsSC">
        </avue-crud>
        <div class="bottom-menu-close">
          <el-button type="primary" @click="visableDialogRecordsSC=false"
            >取消</el-button
          >
        </div>
      </open-dialog>
    </basic-container>
    <Add ref="Add" v-if="isShowDiaAdd"></Add>
    <mergeInfo ref="mergeInfo" v-if="isShowMergeInfo"></mergeInfo>
    <replace ref="replace" v-if="isShowReplace"></replace>
    <report-mistake-info-editor ref="reportMistakeInfoEditor"
                                v-if="isShowReportMistakeInfoEditor"></report-mistake-info-editor>
  <addReportEditor ref="addReportEditor" @addReportSuccess="getList"></addReportEditor>
    <HuikuiInfo ref="HuikuiInfo" v-if="isShowDia"></HuikuiInfo>
    <prev ref="prev" v-if="dialogVisibleprev"></prev>
  </div>

</template>

<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import {mapGetters} from 'vuex';
  import Add from './Add';
  import mergeInfo from './mergeInfo';
  import replace from './replace';
  import reportMistakeInfoEditor from '@/views/subwayRat/reportMondify/reportMistakeInfo/reportMistakeInfoEditor';
  import {
    fenExYuangettoFixed2,
    clearSelect,
    getgetStationCodes,
    getLineCodes, getSysUserToLS, setSearchFiledsEmpty, sortWithDiffMoney
  } from "../../../../api/subwayRat/commonCheck";
  import {
    addReportErrorFromSPY,
    audit_state_pass,
    getOption,
    getSwAuCenterConductorAmountDifferenceList, jiaRuNotice, jiaRuXieCha, mergePersonData,tableOptionEditRecordsSC,queryPastRecords,delObj,revoke,cancellationBomDate
  } from "../../../../api/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/conductorTicketChaYiShenhe";
  import {exportDataToExcel} from "../../../../api/subwayRat/exportSelf";
  import {getSwAuConductorToBeCheckedList} from "../../../../api/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC";
  import transitUtil from "../../../../api/subwayRat/transitUtil";
  import {getDXCSwAuConductorHierarchyAmountDifferenceList} from "../../../../api/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/shouPiaoYuanCJDXY/shoupiaoyuanCJCYDXC/LCAndACCCengJiCYDXC";
  import {getPersonRole} from "../../../../api/subwayRat/reportMondify/reportMistakeInfo";
  import addReportEditor from '@/views/subwayRat/reportMondify/reportMistakeInfo/Editor';
  import HuikuiInfo from "@/views/subwayRat/conductorDifferences/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/HuikuiInfo.vue";
  import prev
    from "@/views/stationTiecketManager/xianWngCJXXQR/shouPiaoYuanPKCY/shouPiaoYuanPKCYQRTZ/otherYunYingZXDLCK/prev.vue";
  import {
    getSwAuConductorNoticeList
  } from "@/api/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/shouPiaoYuanCYQRTZ";

  export default {
    name: 'huLianWangShouPiaojiDataInput',
    components: {
      prev,
      HuikuiInfo,
      Add,
      mergeInfo,
      replace,
      reportMistakeInfoEditor,
      addReportEditor
    },
    data() {
      return {
        dialogVisibleprev:false,//差异确认通知预览
        isShowDia:false,
        conductorPersonNames: [],
        isShowDiaEditor: false,
        isShowDiaAdd: false,
        isShowMergeInfo: false,//是否打开合并信息
        isShowReplace: false,//是否展示替换页面
        option: {},
        listLoading: true,
        lineCodes: [],
        stationCodes: [],
        selectKeys: [],
        selectKeyVals: [],
        searchForm: {
          lineCode: '9',
          stationCode: '',
          conductorPersonName: '',
          isDifferenceAmount: '0',
          auditState: '0',
          isDiffMoney: '0',
	  startdate:'',
	  enddate:''
        },
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          current: 1,// 当前页数
          pageSize: 20, // 每页显示多少条,
          size: 20,// 每页显示多少条
          isAsc: false// 是否倒序
        },
        list: [],
        isShowReportMistakeInfoEditor: false,
        visableDialogRecordsSC: false,
        visableDialogRecordsLC: false,
        visableDialogRecordsACC: false,
        visableDialogRecordsXC: false,
        tableOptionEditRecordsSC:tableOptionEditRecordsSC,
        tableData: [],
      }
    },
    computed: {
          ...mapGetters(['permissions']),
          permissionList () {
            return {
                highDelBomRepeatData: this.vaildData(
                this.permissions.highDelBomRepeatData,
                false
              ),
            };
          }
        },
    watch: {},
    created() {
      this.changeLine("9")
      this.option = getOption();
    },
    methods: {
      //颜色特殊标识
      rowStyle({ row, column, rowIndex }) {
        if (row.isModify == 0) {
          return {
            backgroundColor: "#eee",
            color: "red",
          };
        }
      },
      setSearchFiledsEmpty,
      refreshChange() {
        this.getList()
      },
      changeStation(v) {
        let p = {
          line_code : this.searchForm.lineCode,
          station_code : v
        };
        getSysUserToLS(p).then((response)=>{
          this.conductorPersonNames = response.data.data;
          this.searchForm.conductorPersonName = '';
        });
      },
      async cancellationData(){
        if(this.selectKeys.length == 0){
          this.$message({message: '请勾选数据',type: 'warning'});
          return;
        }
        if(this.selectKeys.length > 1){
          this.$message({message: '只能勾选一条数据',type: 'warning'});
          return;
        }
        for(let i=0;i<this.selectKeys.length;i++){
          if(this.selectKeys[i].auditState==1){
            this.$message.warning("请选择未审核的数据！");
            return;
          }
	  if(this.selectKeys[i].suppState == 3){
            this.$message.warning("请选择未补款的数据！");
            return;
          }
        }
        let res = await this.$confirm('是否确认作废此BOM的所有数据？', '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning'
        });
        if (!res) {
          return;
        }
        let params = this.selectKeys[0];
        cancellationBomDate(params).then((response) => {
          if(response.data.code==0){
            this.$message.success("操作成功！");
          }
          if(response.data.code==1&&this.validatenull(response.data.msg)){
            this.$message.error("操作失败！");
          }
          this.getList();
        }).catch(e=>{
          //   this.$message.error("操作失败！");
        })
      },
      cellStyle({row, column, rowIndex, columnIndex}) {
        if (9 == columnIndex) {
          if (row.differenceAmount < 0) {
            return {
              color: "red",
            };
          } else if (row.differenceAmount > 0) {
            return {
              color: "green",
            };
          }
        }
      },
      getList() {
        const params = this.$route.query;
        const p = {};
        if (Object.keys(params).length) {
          p.lineCode = params.lineCode;
          p.stationCode = params.stationCode;
          /*
	  p.startdate = params.settleBeginTime;
          p.enddate = params.settleEndTime;
	  */
	  // 时间格式化：保留日期部分 + 拼接 "00:00:00"
          p.startdate = params.settleBeginTime ? params.settleBeginTime.split(' ')[0] + ' 00:00:00' : params.settleBeginTime;
          p.enddate = params.settleEndTime ? params.settleEndTime.split(' ')[0] + ' 00:00:00' : params.settleEndTime;

          p.conductorPersonName = params.stationPersonrName;
        }
        this.listLoading = true;
        this.page.size = this.page.pageSize;
        this.page.current = this.page.currentPage;
        Object.assign(this.searchForm, this.page);
        let lineCode = this.searchForm.lineCode;
        let stationCode = this.searchForm.stationCode;
        // Object.assign(this.searchForm, this.$refs.conductorTicketChaYiShenhe ? this.$refs.conductorTicketChaYiShenhe.searchForm : this.searchForm);
        this.searchForm.lineCode = lineCode;
        this.searchForm.stationCode = stationCode;
        this.searchForm.combinStatus = 0;
        //收入日期范围
        let dates1 = this.searchForm.dates1;
        if(dates1!=null && dates1!=''){
          this.searchForm.startdate = dates1[0].substr(0,10);
          this.searchForm.enddate = dates1[1].substr(0,10);
        }
        getSwAuCenterConductorAmountDifferenceList(Object.keys(params).length ? p : this.searchForm).then((response) => {
          // this.list = sortWithDiffMoney(response.data.data,'differenceAmount');//排序 ;
          this.list = response.data.data.records;
          this.listLoading = false;
          this.page.total = response.data.data.total;
        });
      },
      async submitData() {
        if (this.selectKeys.length != 1) {
          this.$message.warning("请选择一条要加入的数据！");
          return;
        }
        for (let i = 0; i < this.selectKeys.length; i++) {
          if (this.selectKeys[i].auditState == 1) {
            this.$message.warning("请选择未审核的数据！");
            return;
          }
//          if(this.selectKeys[i].isMergeRecord!=1){
//            this.$message.warning("请选择合并的数据！");
//            return;
//          }
        }
        let res = await this.$confirm('是否提交报表差错？', '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning'
        });
        if (!res) {
          return;
        }
        this.selectKeys[0].reportNameId = '1';
        // this.$router.push({ path: '/subwayRat/reportMondify/reportMistakeInfo',query:{row:this.selectKeys[0]}})
        //this.addContent("添加报表差错", 0);
        let param={
          resultIds:this.selectKeys[0].id,
          operatorTable:"sw_au_center_conductor_amount_difference",
          lineCode:this.selectKeys[0].lineCode,
          stationCode:this.selectKeys[0].stationCode,
          bomCode:this.selectKeys[0].bomCode,
          reprotTime:this.selectKeys[0].recordTime,
          reportNameId:1,
          deviceNo:this.selectKeys[0].equipmentNumber,
          settleBeginTime:this.selectKeys[0].incomeSettleBeginTime,
          settleEndTime:this.selectKeys[0].incomeSettleEndTime,
          userCodes:this.selectKeys[0].conductorJobNo,
	  dutyStationLeaderCode:this.selectKeys[0].passengerJobNo,
	  dutyStationLeaderName:this.selectKeys[0].passengerJobName,
          showType:3,
          dataSource:3,
	  errorAmount:fenExYuangettoFixed2(this.selectKeys[0].differenceAmount)
        };
        this.$refs.addReportEditor.others_report_add_call(param);
      },
      jiaRuXieCha() {
        if (this.selectKeys.length <= 0) {
          this.$message.warning("请选择要下发的数据！");
          return;
        }
        for (let i = 0; i < this.selectKeys.length; i++) {
          if (this.selectKeys[i].assitAuditSate > 1) {
            this.$message.warning("请选择未协查的数据！");
            return;
          }
          if (this.selectKeys[i].auditState == 1) {
            this.$message.warning("审批通过的数据不能加入协查！");
            return;
          }
        }
        jiaRuXieCha({ids: this.selectKeyVals.join(",")}).then(res => {
          if (res.data.code == 0) {
            this.$message.success("操作成功！");
            this.getList();
            // clearSelect(this.$refs.conductorTicketChaYiShenhe);
          } else {
            this.$message.error(res.data.msg);
          }
        })
      },
      jiaRuNotice() { //加入通知
        if (this.selectKeys.length <= 0) {
          this.$message.warning("请选择要下发的数据！");
          return;
        }
        for (let i = 0; i < this.selectKeys.length; i++) {
          if (this.selectKeys[i].noticeSate > '1') {
            this.$message.warning("请选择未通知的数据！");
            return;
          }
          if (this.selectKeys[i].auditState == 1) {
            this.$message.warning("审批通过的数据不能加入确认通知！");
            return;
          }
        }
        jiaRuNotice({ids: this.selectKeyVals.join(",")}).then(res => {
          if (res.data.code == 0) {
            this.$message.success("操作成功！");
            this.getList();
            // clearSelect(this.$refs.conductorTicketChaYiShenhe);
          } else {
            this.$message.error(res.data.msg);
          }
        })
      },
      async audit_state_pass() { //审批收入审核
        if (this.selectKeys.length <= 0) {
          this.$message.warning("请选择要审批的数据！");
          return;
        }
        let ids = [];
        for (let i = 0; i < this.selectKeys.length; i++) {
          if (this.selectKeys[i].auditState == 1) {
            this.$message.warning("请选择未审批的数据！");
            return;
          }
          if(this.selectKeys[i].isModify == 0){
            // this.$message.warning("勾选数据中存在报表差错未完成的数据！");
            // return;
          } else {
            ids.push(this.selectKeys[i].id)
          }
        }
        let res = await this.$confirm('是否一键审核？', '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning'
        });
        if (!res) {
          return;
        }
        let response = await audit_state_pass({ids: ids.join(",")});
          if (response.data.code == 0) {
            this.$message.success("操作成功！");
            this.getList();
            // clearSelect(this.$refs.conductorTicketChaYiShenhe);
          } else {
            this.$message.error(response.data.msg);
          }
      },

      mergePersonData() { //合并数据
        if (this.selectKeys.length <= 1) {
          this.$message.warning("合并的数据最少大于一条！");
          return;
        }
        let sysDataSource = '';
	let comLineCode = '';
	let comStationCode = '';
	let comRecordTime = '';
        for (let i = 0; i < this.selectKeys.length; i++) {
          if (this.selectKeys[i].auditState == 1) {
            this.$message.warning("请选择未审核的数据！");
            return;
          }
	  if (this.selectKeys[i].suppState != 0) {
            this.$message.warning("合并的数据中存在加入售票员确认通知的数据！");
            return;
          }
          if (i > 0 && sysDataSource != this.selectKeys[i].sysDataSource) {
            this.$message.warning("系统来源不一致，请修改系统来源！");
            return;
          }
	  if (i > 0 && comLineCode != this.selectKeys[i].lineCode) {
            this.$message.warning("线路不一致，请选择同一条线路数据！");
            return;
          }
	  if (i > 0 && comStationCode != this.selectKeys[i].stationCode) {
            this.$message.warning("车站不一致，请选择同一个车站数据！");
            return;
          }
	  if (i > 0 && comRecordTime != this.selectKeys[i].recordTime) {
            this.$message.warning("收入日期不一致，请选择同一收入日期数据！");
            return;
          }
          sysDataSource = this.selectKeys[i].sysDataSource;
	  comLineCode = this.selectKeys[i].lineCode;
	  comStationCode = this.selectKeys[i].stationCode;
          comRecordTime = this.selectKeys[i].recordTime;
        }
        this.$confirm("确认合并结算?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          mergePersonData({ids: this.selectKeyVals.join(",")}).then(res => {
            if (res.data.code == 0) {
              this.$message.success("操作成功！");
              this.getList();
              // clearSelect(this.$refs.conductorTicketChaYiShenhe);
            } else {
              this.$message.error(res.data.msg);
            }
          })
        });
      },
      async cengJiXieCha(row) { //层级差异协查
        let res = await getDXCSwAuConductorHierarchyAmountDifferenceList({relationid: row.id});
        let form = this.searchForm;
        if (res.data.data.length >= 0) {
          let d = res.data.data[0];
          if (d.comparativeType == 1) { // SC与LC对比
            this.$router.push({
              path: '/subwayRat/conductorDifferences/shouPiaoYuanCJCY/ScAndLcCengJiCYDXC',
              query: {conductorTicketChaYiShenhe: form}
            });
          } else if (d.comparativeType == 2) {// LC与ACC对比
            this.$router.push({
              path: '/subwayRat/conductorDifferences/shouPiaoYuanCJCY/LCAndACCCengJiCYDXC',
              query: {conductorTicketChaYiShenhe: form}
            });
          }
        }
      },
     /* actionMarketTicket(row){
        this.$router.push({path:'/subwayRat/conductorDifferences/SwAuConductorShort/swStMarketingTicket',query:{param:row}});
      },
      */
      actionMarketTicket(row) { //营销车票
        let feedbackPath = '/subwayRat/conductorDifferences/SwAuConductorShort/swStMarketingTicket';
        this.$router.push({path: feedbackPath, query: row});
      },
//       async xieChaInfo(row){//协查信息
//         let res=await getSwAuConductorToBeCheckedList({differenceId:row.id});
//           if(res.data.data.length>=0){
//             let d=res.data.data[0];
//             let feedbackPath='';
//             let feedbackEventStr='';
//             if(d.assistState==1){ //待协查，跳转到票款差异待协查列表
//               feedbackPath='/subwayRat/conductorDifferences/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC';
//             }else if(d.assistState==2){ //协查中
//               this.$message.info("等待回馈")
//               return;
//             }else if(d.assistState==3){ //已协查，跳转到票款差异待协查，回馈页面
//               feedbackPath='/subwayRat/conductorDifferences/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC';
//               feedbackEventStr="shouPiaoYuanPKCYDXC_call";
//             }else{
//               return;
//             }
//             this.$router.push({path:feedbackPath,query:row});
//             setTimeout(function () {
//               transitUtil.$emit(feedbackEventStr,row);
//             },100);
// =======
      //差异确认通知预览
      async previewNotice(row) {
        let res = await getSwAuConductorNoticeList({relationId: row.id});
        if (res.data.data.length >= 0) {
          this.dialogVisibleprev=true;
          this.$nextTick(()=>{
            this.$refs.prev.dialogVisible=true;
            this.$refs.prev.recallShow(res.data.data[0],this);
          })
        }
      },
      async xieChaInfo(row) {//协查信息
        let res = await getSwAuConductorToBeCheckedList({differenceId: row.id});
        if (res.data.data.length >= 0) {
          let d = res.data.data[0];
          let th=this;
          getSwAuConductorToBeCheckedList({differenceId:row.id}).then((response)=>{
            th.data = response.data.data;
            th.previewEditor(th.data[0]);
          });
          // let feedbackPath = '';
          // let feedbackEventStr = '';
          // if (d.assistState == 1) { //待协查，跳转到票款差异待协查列表
          //   feedbackPath = '/subwayRat/conductorDifferences/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC';
          // } else if (d.assistState == 2) { //协查中
          //   this.$message.info("等待回馈")
          //   return;
          // } else if (d.assistState == 3) { //已协查，跳转到票款差异待协查，回馈页面
          //   feedbackPath = '/subwayRat/conductorDifferences/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC';
          //   feedbackEventStr = "shouPiaoYuanPKCYDXC_call";
          // } else {
          //   return;
          // }
          // this.$router.push({path: feedbackPath, query: row});
          // setTimeout(function () {
          //   transitUtil.$emit(feedbackEventStr, row);
          // }, 100);
        }
      },
      previewEditor(row){ //回馈预览
        this.isShowDia=true;
        this.$nextTick(()=>{
          this.$refs.HuikuiInfo.recallShow(row);
        })
      },
      lookChengkeShiwu(row) { //查看乘客事务
        let feedbackPath = '/subwayRat/conductorDifferences/passengersTransaction/passengersTransactionAudit/swStInputPassengerWork';
        this.$router.push({path: feedbackPath, query: row});
      },
      addData() {
        this.isShowDiaAdd = true;
        this.$nextTick(() => {
          this.$refs.Add.dialogVisible = true;
          this.$refs.Add.recallShow(null, null, 2);
        })
      },
      editor(row) {
        this.isShowDiaAdd = true;
        this.$nextTick(() => {
          this.$refs.Add.dialogVisible = true;
          this.$refs.Add.recallShow(null, row, 1);
        })
      },
      preview(row) {
        this.isShowDiaEditor = true;
        this.$nextTick(() => {
          this.$refs.Editor.dialogVisible = true;
          this.$refs.Editor.recallShow(null, row, 3);
        })
      },
      openMergeInfo(row) {
        this.isShowMergeInfo = true;
        this.$nextTick(() => {
          this.$refs.mergeInfo.dialogVisible = true;
          this.$refs.mergeInfo.getLists(row);
        })
      },
      openReplace(row) {
        this.isShowReplace = true;
        this.$nextTick(() => {
          this.$refs.replace.dialogVisible = true;
          this.$refs.replace.getLists(row);
        })
      },
      selectionChange(list) {
        this.selectKeys = list;
        this.selectKeyVals = [];
        for (let i = 0; i < list.length; i++) {
          this.selectKeyVals.push(list[i].id);
        }
      },
      handleFilter(params, done) {
        Object.assign(this.searchForm, params);
        this.getList()
        done()
      },
      async exportData() { // 导出
        // this.$refs.conductorTicketChaYiShenhe.toggleSelection(this.$refs.conductorTicketChaYiShenhe.data);
        // console.log(this.$refs.conductorTicketChaYiShenhe);
        // console.log(this.$refs.conductorTicketChaYiShenhe.tableSelect);
        // console.log(this.$refs.conductorTicketChaYiShenhe.tableSelect[0].lineCode)
        // console.log(this.$refs.conductorTicketChaYiShenhe.t(this.$refs.conductorTicketChaYiShenhe.tableSelect[0].lineCode));
        let p = {};
        Object.assign(this.searchForm, this.$refs.conductorTicketChaYiShenhe ? this.$refs.conductorTicketChaYiShenhe.searchForm : {});
        Object.assign(p, this.searchForm);
        p.pageNo = 1;
        p.pageSize = 1000000000;
        p.size=1000000000;
        if (this.selectKeys.length > 0) {
          let newData = JSON.parse(JSON.stringify(this.selectKeys));
          exportDataToExcel(newData, this.option.column, '售票员票款差异');
        } else {
          let res = await getSwAuCenterConductorAmountDifferenceList(p);
          let data = sortWithDiffMoney(res.data.data.records, 'differenceAmount');//排序 ;
          exportDataToExcel(data, this.option.column, '售票员票款差异');
        }
      },
      test(row, index) {
        console.log('shuju', row)
      },
      changeLine(v) { //改变线路时
        getgetStationCodes(v).then(res => {
          this.stationCodes = res;
          this.searchForm.stationCode = '';
        })
      },
      addContent(title, showType) {
        this.isShowReportMistakeInfoEditor = true;
        this.$nextTick(() => {
          this.$refs.reportMistakeInfoEditor.showType = 0;
          this.$refs.reportMistakeInfoEditor.dialogTitle = title;
          this.$refs.reportMistakeInfoEditor.clearParam();
          this.$refs.reportMistakeInfoEditor.previewEditor({});
          this.$refs.reportMistakeInfoEditor.param.lineCode = this.$store.getters.userInfo.lineCode;
          this.$refs.reportMistakeInfoEditor.param.stationCode = this.$store.getters.userInfo.stationCode;
          // this.$refs.reportMistakeInfoEditor.param.reprotTime = moment();
        });
      },
      async queryPastRecords(row){
        let param={};
        param.id=row.id;
        await queryPastRecords(param)
          .then(response => {
              this.tableData = response.data.data;
          })
      },
      openPastRecords(row){
        this.queryPastRecords(row);
        this.visableDialogRecordsSC=true;
        // if(row.dataSource==1){
        //   this.visableDialogRecordsSC=true;
        // }else if(row.dataSource==2){
        //   this.visableDialogRecordsLC=true;
        // }else if(row.dataSource==3){
        //   this.visableDialogRecordsACC=true;
        // }else if(row.dataSource==4){
        //   this.visableDialogRecordsXC=true;
        // };
      },
      //删除重复数据
      handleDeleteRepeat: function () {
        if (this.selectKeys.length === 0) {
          this.$message.error('请选择要去重的数据！');
          return;
        }
	if (this.selectKeys.length > 1) {
          this.$message.error('只能选择一条要去重的数据！');
          return;
        }
        /*
	for(let i =0;i<this.selectKeys.length;i++){
          if(this.selectKeys[i].auditState==1){
            this.$message.warning("审批通过的数据不允许删除！");
            return;
          }
        }*/
        this.$confirm("是否需要去重?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "success"
        }).then(() => {
          delObj({ids: this.selectKeyVals,flag:'2'})
            .then(data => {
              if (data.data.code == "0") {
                this.$message.success("去重成功");
              }
              this.getList(this.page);
              done();
            })
            .catch(() => {
              loading();
            });
        });
      },
      //删除
      handleDelete: function () {
        if (this.selectKeys.length === 0) {
          this.$message.error('请选择要删除的数据！');
          return;
        }
	if (this.selectKeys.length > 1) {
          this.$message.error('只能选择一条要删除的数据！');
          return;
        }

	for(let i =0;i<this.selectKeys.length;i++){
          if(this.selectKeys[i].auditState==1){
            this.$message.warning("审批通过的数据不允许删除！");
            return;
          }
        }
        this.$confirm("是否需要删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "success"
        }).then(() => {
          delObj({ids: this.selectKeyVals,flag:'1'})
            .then(data => {
              if (data.data.code == "0") {
                this.$message.success("删除成功");
              }
              this.getList(this.page);
              done();
            })
            .catch(() => {
              loading();
            });
        });
      },
      //审核通过的才能撤回
      revoke: function () {
        if (this.selectKeys.length === 0) {
          this.$message.error('请选择要撤回的数据！');
          return;
        }
        for(let i =0;i<this.selectKeys.length;i++){
          if(this.selectKeys[i].auditState==0){
            this.$message.warning("只能撤回审批通过的数据！");
            return;
          }
        }
        this.$confirm("是否需要撤回?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "success"
        }).then(() => {
          revoke({ids: this.selectKeyVals})
            .then(data => {
              if (data.data.code == "0") {
                this.$message.success("撤回成功！");
              }
              this.getList(this.page);
              done();
            })
            .catch(() => {
              loading();
            });
        });
      },
    },
    mounted() {
      getLineCodes().then(res => { //获取线路
        this.lineCodes = res;
      });
    }
  }
</script>
<style lang="scss">
  .huLianWangShouPiaojiDataInput {
    height: 100%;

    &__tree {
      padding-top: 3px;
      padding-right: 20px;
    }

    &__main {
      .el-card__body {
        padding-top: 0;
      }
    }

    .avue-form__group {

    }
  }
  .bottom-menu-close{
    text-align: center;
    margin-top: 50px;
  }
</style>
